home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2987 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  872 b 

  1. Path: news.lpr.carel.fi!usenet
  2. From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Split Filename
  5. Date: Thu, 25 Jan 1996 12:47:16 +0200
  6. Organization: Carelcomp Forest
  7. Message-ID: <31075FB4.3E53@cmt.lpr.mail.carel.fi>
  8. References: <4e6lsr$8ar@news1.radix.net>
  9. NNTP-Posting-Host: renoir.cclahti.carel.fi
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b6a (WinNT; I)
  14.  
  15. Jim Ward wrote:
  16. > Is there a C function that will split
  17. > /home/file.c into /home and file.c ?
  18. > Thanks,
  19. > Jim Ward
  20.  
  21. You could try:
  22.  
  23.     char    pathandfile[] = "/home/file.c";
  24.     char    *path = pathandfile;
  25.     char    *p = strrchr(pathandfile, '/');
  26.     char    *filename = p + 1;
  27.     *p = '\0';
  28.  
  29. Also, some systems have functions named makepath and splitpath.
  30.  
  31. Later,
  32. AriL
  33.  
  34.     
  35. -- 
  36. All my opinions are mine and mine alone.
  37.